<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>点击调度（制定了安全配置单）</title>
    <link rel="shortcut icon" href="favicon.ico">
    <link href="/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="/css/animate.css" rel="stylesheet">
    <link href="/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="/bootstraptable/bootstrap-table.css" rel="stylesheet">
    <style>
        .text_no_border {
            border: none;
        }
    </style>
</head>
<body>
<div style="color: #0e9aef;">您正在做的业务是：库存管理--出入库调度管理--制定入库单</div>

<div class="container">
    <div style="text-align: right;">
        <button type="button" class="btn btn-default" id="submitBtn">提交</button>
        <button type="button" class="btn btn-default" onclick="javascript:history.back()">返回</button>
    </div>
    <div class="panel panel-default" style="margin-top: 5px;">
        <div class="page-heading">
            <div class="panel-title">
                <h2 style="text-align: center;margin-top: 20px;">入库调度单</h2>
            </div>
        </div>
        <div class="panel-body">
            <form class="form-horizontal" id="establish_inbound_scheduling_byId_form">
                <input type="hidden" name="id" id="id">
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">入库单编号：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="gatherId" name="gatherId">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">产品编号：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="productId" name="productId">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">产品名称：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="productName" name="productName">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">成本单价：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="costPrice" name="costPrice">
                        </div>
                    </div>
                </div>
                <div class="form-group">
<!--                    <div class="col-md-6">-->
<!--                        <label class="control-label col-md-4">当前可存放数量：</label>-->
<!--                        <div class="col-md-8">-->
<!--                            <input type="text" class="text_no_border form-control"-->
<!--                                   style="border: none;border-bottom: 1px solid black;"-->
<!--                                   id="" name="">-->
<!--                        </div>-->
<!--                    </div>-->
                    <div class="col-md-6">
                        <label class="control-label col-md-4">本次入库数量：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   style="border: none;border-bottom: 1px solid black;"
                                   id="gatheredAmount" name="gatheredAmount">
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <div class="col-md-6">
                        <label class="control-label col-md-4">应入库数：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="amount">
                        </div>
                    </div>
                    <div class="col-md-6">
                        <label class="control-label col-md-4">应入库成本：</label>
                        <div class="col-md-8">
                            <input type="text" class="text_no_border form-control"
                                   readonly style="background-color: white;" id="subtotal" name="subtotal">
                        </div>
                    </div>
                </div>

            </form>
        </div>
    </div>
</div>


<!-- 全局js -->
<script src="/js/jquery.min.js?v=2.1.4"></script>
<script src="/js/bootstrap.min.js?v=3.3.6"></script>
<script src="/js/plugins/metisMenu/jquery.metisMenu.js"></script>
<script src="/js/plugins/slimscroll/jquery.slimscroll.min.js"></script>
<script src="/js/plugins/layer/layer.min.js"></script>

<!-- 自定义js -->
<script src="/js/hAdmin.js?v=4.1.0"></script>
<script src="/js/currentTime.js"></script>

<!-- 第三方插件 -->
<script src="/js/plugins/pace/pace.min.js"></script>

<!--BootstrapTable-->
<script src="/bootstraptable/bootstrap-table.min.js"></script>
<script src="/bootstraptable/locale/bootstrap-table-zh-CN.min.js"></script>

<script>
    $(function () {
        let id = localStorage.getItem("detailsId")
        $("#establish_inbound_scheduling_byId_form #attemperTime").val(add(fortime()))

        //查询入库明细
        $.post("/storage/gather/getIdQueryStorageDetails", {"id": id}, function (res) {
            $("#establish_inbound_scheduling_byId_form #productId").val(res.productId)
            $("#establish_inbound_scheduling_byId_form #id").val(res.id)
            $("#establish_inbound_scheduling_byId_form #productName").val(res.productName)
            $("#establish_inbound_scheduling_byId_form #costPrice").val(res.costPrice)
            $("#establish_inbound_scheduling_byId_form #amount").val(res.amount)
            $("#establish_inbound_scheduling_byId_form #subtotal").val(res.subtotal)
            $("#establish_inbound_scheduling_byId_form #gatherId").val(localStorage.getItem("gatherId"))
        })

        //点击提交按钮
        $("#submitBtn").click(function () {
            let num = $("#establish_inbound_scheduling_byId_form #gatheredAmount").val()
            let num1 = $("#establish_inbound_scheduling_byId_form #amount").val()
            //判断输入数量
            if (num != num1) {
                alert("入库数量有误，请重新输入数量")
                return
            }
            let parms = $("#establish_inbound_scheduling_byId_form").serialize()
            let gatherId= $("#establish_inbound_scheduling_byId_form #gatherId").val()
            $.post("/storage/gather/updGatherWithDetail", parms, function (res) {
                if(res){
                    $.post("/storage/gather/getGatherId", {"gatherId":gatherId}, function (data) {
                        if (data==false) {
                            window.location="formulate_warehousingByIdUI"
                        } else {
                            window.location = "formulate_warehousingUI"
                        }
                    })
                }
            })
        })
    })
</script>
</body>
</html>